'use strict';
module.exports = {
  async up (queryInterface, Sequelize) {
    await queryInterface.createTable('punch_plans', {
      id: {
        allowNull: false,
        autoIncrement: true,
        primaryKey: true,
        type: Sequelize.INTEGER
      },
      userId: {
        type: Sequelize.INTEGER,
        allowNull: false,
        comment: '所属用户ID'
      },
      name: {
        type: Sequelize.STRING(10),
        allowNull: false,
        comment: '打卡名称，必填，字数不超过10个字'
      },
      days: {
        type: Sequelize.INTEGER,
        allowNull: false,
        defaultValue: 0,
        comment: '打卡天数，必填，默认0，0表示不限制天数'
      },
      desc: {
        type: Sequelize.STRING(200),
        allowNull: true,
        comment: '详细的文字描述，非必填，限制200字'
      },
      created_at: {
        allowNull: false,
        type: Sequelize.DATE,
        defaultValue: Sequelize.literal('CURRENT_TIMESTAMP')
      },
      updated_at: {
        allowNull: false,
        type: Sequelize.DATE,
        defaultValue: Sequelize.literal('CURRENT_TIMESTAMP')
      }
    });
  },

  async down (queryInterface, Sequelize) {
    await queryInterface.dropTable('punch_plans');
  }
};
